package com.the_ring.behavior.visitor;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @author: t22306139
 * @date: 2023/12/1  15:15
 */
public class ElementSet {

    private List<Element> list = new ArrayList<>();

    public String accept(Visitor visitor) {
        Iterator<Element> iterator = list.iterator();
        StringBuilder result = new StringBuilder();
        while (iterator.hasNext()) {
            result.append(iterator.next().accept(visitor)).append(" ");
        }
        return result.toString();
    }

    public void add(Element element) {
        list.add(element);
    }

    public void remove(Element element) {
        list.remove(element);
    }
}
